//  https://www.luogu.com.cn/problem/P1036

#include<iostream>
using namespace std;

int n, k;
int ret;
int path;
const int N = 25;
int a[N];

bool isprime(int x)
{
    if (x <= 1) return false;

    for (int i = 2;i <= x / i;i++)
    {
        if (x % i == 0) return false;
    }
    return true;
}

void dfs(int pos, int begin)
{
    if (pos > k)
    {
        if (isprime(path))
            ret++;
        return;
    }
    for (int i = begin;i <= n;i++)
    {
        path += a[i];
        dfs(pos + 1, i + 1);
        path -= a[i];
    }
}
int main()
{
    cin >> n >> k;
    for (int i = 1;i <= n;i++) cin >> a[i];

    dfs(1, 1);
    cout << ret << endl;
    return 0;
}